import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
if __name__=="__main__":
    f=r"D:\Tetuan City power consumption.csv"
    data=pd.read_csv(f)
    # print(data.head())
    # print(data)
    data.columns=['x1','x2','x3','x4','x5','x6','y1','y2','y3']
    #第一列是递增的日期时间看作是索引不予考虑
    x=sm.add_constant(data.iloc[:,1:6])#生成自变量
    # print(x)
    y=data['y1']#生成因变量
    # print(y)
    model=sm.OLS(y,x)#生成模型
    result=model.fit()#模型拟合
    print(result.summary())#模型描述

